<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script>
			/* alert('hie');
			prompt(''); */
		</script>
		<script>
			//声明
			var age;
			age = 10;
			console.log(age);
			//声明并赋值
			//var name = "sss"; name 有特殊含义不要用name进行声明
			/* console.log(prompt('sss')); */
			var name2 = "ss",
				address = "ssss",
				phone = "123";
			var let;
			console.log(let);//undefined;
			var app = 10;
			var App = 100;
			//要严格区分大小写，不能以数字开头，驼峰命名法，变量名要有意义，不能是关键则或者是保留字：var while for
			//交换变量
			var temp;
			var redApple = "红",
				blueApple = "蓝";
			temp = redApple;
			redApple = blueApple;
			blueApple = temp;
			console.log(redApple);
			console.log(blueApple);
			console.log(temp);
			//可以直接改变数据类型
			var num = 1;
				num = "1";
			console.log(typeof num);
			/* 
				boolean 
				number
				string
				undefined
				null
			*/
			var num2 = 1;
			var PI = 3.14//数字型，小数型
			//1.八进制0~7 前面加零表示八进制
			var num3 = 010;//转换成十进制就是8
			console.log(num3);
			var num4 = 023;
			console.log(num4);
			// 0 - 9 - a - f 前面家 0x 表示十六进制 
			var num5 = 0x9;
			console.log(num5);
			var num6 = 0xa;
			var num7 = 0x1f;//31
			console.log(num7);
			//最大值
			console.log(Number.MAX_VALUE);
			//最小值
			console.log(Number.MIN_VALUE);
			//无穷大值
			console.log(Number.MAX_VALUE * 2);//Infinity
			//无穷小
			console.log(-Number.MIN_VALUE * 2);//-Infinity
			//非数字
			console.log("ss" - 100);//NaN        not a Namber
			//判断是否为数字
			console.log(isNaN(12));//false
			console.log(isNaN("ss"));//true
			//字符串
			console.log('sdfasdfs"a"d\\f');
			/* 
				转义符	表示
				\\   	\
				\n		换行
				\' 		'
				\"		"
				\t		tab缩进
				\b		空格blank
			*/
			//布尔类型
			var flag = true;
			var flag2 = false;
			console.log(flag + 1);//2
			console.log(flag2 + 1);//1
			//undefined
			var str = undefined;
			console.log(str + "ss");//undefinedss
			console.log(str + 1);//NaN
			//判断类型
			console.log(typeof str);//Object
			//类型转换
			var num9 = 33;
			console.log(num9.toString());
			console.log(String(num9));
			console.log(num9*"");//隐式转换
			var str2 = "12.11";
			console.log(parseInt(str2));
			console.log(str2 + 1);//隐式转换
			console.log(parseFloat(str2));
			console.log(parseInt("str2"));//NaN
			console.log(Number(str2));
			//布尔类型转换
			console.log(Boolean(""));//false
			console.log(Boolean(0));//false
			console.log(Boolean(NaN));//false
			console.log(Boolean(undefined));//false
			//--------------------------代表空或者否定得值结果会为false，例子如上
			console.log(Boolean("q1"));//true
			console.log(Boolean(1));//true
			//递增递减
			var num10 = 10;
			console.log(++num10 + 10);//21,,返回++后的值
			console.log(num10++ + 10);//20 ,, 先返回原值
			var e = 10;
			var f = e++ + ++e;//1.e=10 e++ 11 + e = 11 ++e = 12           12 + 10 = 22
			console.log(f);//22
			//判断
			console.log(10 == "10");//true
			console.log(10 === "10");//false //全等符号
			console.log(10 !== 10);//false
			console.log(e !== f);//true
			//短路运算（逻辑中断）
			console.log(123 && 456);//456 返回表达式2
			console.log(0 && 456);//0 返回表达式1
			console.log(0 && 456 && 2 * 10);//0
			//赋值
			var a;
			a += 2;
			a *= 2;
			a -= 2;
			console.log(1<2?'是的':'no');
			//京东秒杀
			var time = 8;
			console.log(8<10?'0'+time:time);
			//switch
			switch(10){
				case 1:
					break;
					default:
						break
			}
			//循环
			for(var i = 0; i　< 2; i++){

			}
			while(false){

			}
			do{

			}while(false);
			var even = 0;
			var odd = 0;
			for(var i = 0; i <= 100; i++){
				i%2==0?even += i:odd += i;
			}
			console.log(even);
			var str3 = '';
			for(var i = 1; i <= 10; i++){
				for(var j = i;j <=10; j++){
					str3 += '*';
				}
				str3 += '\n';
			}
			console.log(str3);
			var num11 = '';
			for(var i = 1; i <= 9; i++){
				for(var j = 1; j <= i; j++){
					num11 += i+'*'+j+'='+i*j+'\t'
				}
				num11 += '\n';
			}
			console.log(num11);
			for(var i = 1; i <= 4; i++){
				if(i==2){
					continue;
				}
			}
			//命名规范，变量用名词命名，函数用动词命名
			var array = new Array();
			var array2 = [];
			var array3 = [1,2,'22',true];
			console.log(array3[0]);
			for(var i = 0;i < 10; i++){
				array2[i] = i;
			}
			var array4 = [1,3,4,0,0,0];
			var newArray = [];
			for(var i = 0; i <= array4.length; i++){
				if(array4[i]==0){
					newArray[newArray.length] = array4[i];
				}
			}
			console.log(newArray);
			var arrayNumber = [1,2,3,4,5]
			var temp2 = 0;
			for(var i = 0; i <= arrayNumber.length-1;i++){
				for(var j = 0; j <= arrayNumber.length-i-1; j++){
					if(arrayNumber[j]<arrayNumber[j+1]){
						temp2 = arrayNumber[j];
						arrayNumber[j] = arrayNumber[j+1];
						arrayNumber[j+1] = temp2; 
					}
				}
			}
			console.log(arrayNumber);
			
		</script>
	</head>
	<body>
		
	</body>
</html>
